<?php
define("SYS_PATH",dirname(__FILE__)."/");

include_once 'gift_cert/lib/Common.php';
include_once 'gift_cert/lib/ImageText.php';

//if is post
if(isset($_POST['u_name']) == true)
{
	// Set the content-type
	header("Content-type: image/jpg");
	
	//get post params
	$inputArray = array();
	$inputArray['amount'] = $_POST['amount'];
	$inputArray['from'] = $_POST['u_name'];
	$inputArray['to'] = $_POST['r_name'];
	$inputArray['message'] = $_POST['r_message'];
	$inputArray['template'] = $_POST['chkTemplate'];
	$inputArray['code'] = "GC20091111";
	
	$im = ImageText::createImage($inputArray);
	
	imagejpeg($im);
	imagedestroy($im);
}
else
{
?>
<html>
<head>
<style type="text/css" media="screen">
	.imgTpl{
	border:1px solid black;
	}
}
</style>

<script type="text/javascript" src="js/prototype.js"></script>
<script type="text/javascript" src="js/scriptaculous.js?load=effects,builder"></script>
<script type="text/javascript" src="js/lightbox.js"></script>
<script type="text/javascript" src="js/common.js"></script>
<link rel="stylesheet" href="css/lightbox.css" type="text/css" media="screen" />
</head>
<body>
<form action="" method="post">

<table width="480" border="0" cellpadding="5" cellspacing="5" align="center">
<tr height="40">
<td>
<span class="how-it-works-bold"><h1>Test template</h1></span>
<br>
<h3>Edit template.xml file to see how the text appeared.</h3>
</td>
</tr>

<tr height="40"><td>Amount:<br>
<input type="text" maxlength="7" name="amount" id="amount" size="20" value="1000">
</td></tr>

<tr height="40"><td>Your name:<br>
<input type="text" maxlength="50" name="u_name" id="u_name" size="50" value="Thuan Doan Vu">
</td></tr>

<tr height="40"><td>Recipient's name:<br>
<input type="text" maxlength="50" name="r_name" id="r_name" size="50" value="Phuc Ngo Hoang">
</td></tr>

<tr height="40"><td>Message: (Maximum Message Length 50 Characters)<br>
<textarea name="r_message" id="r_message" cols="38" rows="2" maxlength="50" onkeydown="return ismaxlength(this,event);"  onkeyup="return limitMsg(this,event);">Happy Birthday to you!</textarea>
</td></tr>

<tr><td>
Certificate design (click on thumbnail to see full size image):

<table border="0">
<tr><td><a href="images/gift_cert/tpl1.jpg" rel="lightbox" title="Template 1" >
<img src="images/gift_cert/tpl1thumb.jpg"></a></td>
<td width="50">&nbsp;</td>
<td><a href="images/gift_cert/tpl2.jpg" rel="lightbox" title="Template 2" >
<img src="images/gift_cert/tpl2thumb.jpg"></a></td></tr>
<tr><td align="center"><input type="radio" name="chkTemplate" id="tpl1" value="tpl1" checked="checked"></td>
<td>&nbsp;</td>
<td align="center"><input type="radio" name="chkTemplate" id="tpl2" value="tpl2"></td></tr>

<tr><td><a href="images/gift_cert/tpl3.jpg" rel="lightbox" title="Template 3" >
<img src="images/gift_cert/tpl3thumb.jpg"></a></td>
<td>&nbsp;</td>
<td><a href="images/gift_cert/tpl4.jpg" rel="lightbox" title="Template 4" >
<img src="images/gift_cert/tpl4thumb.jpg"></a></td></tr>
<tr><td align="center"><input type="radio" name="chkTemplate" id="tpl3" value="tpl3"></td>
<td>&nbsp;</td>
<td align="center"><input type="radio" name="chkTemplate" id="tpl4" value="tpl4"></td></tr>

<tr><td><a href="images/gift_cert/tpl5.jpg" rel="lightbox" title="Template 5" >
<img src="images/gift_cert/tpl5thumb.jpg"></a></td>
<td>&nbsp;</td>
<td><a href="images/gift_cert/tpl6.jpg" rel="lightbox" title="Template 6" >
<img src="images/gift_cert/tpl6thumb.jpg"></a></td></tr>
<tr><td align="center"><input type="radio" name="chkTemplate" id="tpl5" value="tpl5"></td>
<td>&nbsp;</td>
<td align="center"><input type="radio" name="chkTemplate" id="tpl6" value="tpl6"></td></tr>

</table>	
	
</td></tr>

<tr height="40"><td valign="bottom">
<input type="image" src="images/continue.png" onmouseover="this.src='images/continue_f2.png'" onmouseout="this.src='images/continue.png'" width="117" height="37" border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!">
</td></tr>

</table>
</form>
</body>
</html>
<?php } ?>